package com.example.multilevelapprovalback.controller;
import com.example.multilevelapprovalback.pojo.PageBean;
import com.example.multilevelapprovalback.pojo.Result;
import com.example.multilevelapprovalback.pojo.TeachingProject;
import com.example.multilevelapprovalback.service.TeachProjService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.Year;
import java.util.List;
/**
 * 教学项目管理
 */
@Slf4j
@RestController
@RequestMapping("/teaching-projects")
public class TeachProjController {
    @Autowired
    private TeachProjService teachProjService;
    //添加教学项目
    @PostMapping
    public Result save(@RequestBody TeachingProject teachingProject) {
        log.info("新增教学项目：{}",teachingProject);
        teachProjService.save(teachingProject);
        return Result.success();
    }
    //修改教学项目
    @PutMapping
    public Result update(@RequestBody TeachingProject teachingProject) {
        log.info("更新教学项目：{}",teachingProject);
        teachProjService.update(teachingProject);
        return Result.success();
    }
    //根据ID删除对应的教学项目
    @DeleteMapping("/{ids}")
    public Result delete(@PathVariable List<String> ids) {
        log.info("批量删除操作：ids:{}",ids);
        teachProjService.delete(ids);
        return Result.success();
    }
    //分页查询教学项目
    @GetMapping
    public Result page(@RequestParam(defaultValue = "1") Integer page,  //请求第几页数据
                       @RequestParam(defaultValue = "10") Integer pageSize,  //一页显示多少条数据
                       Integer roleId,  //用户角色ID
                       String name,  //用户姓名
                       String jobNumber,  //用户工号
                       String startTime,  //起始时间
                       String endTime,//终止时间
                       Integer statusId,  //项目状态ID
                       String projectName,  //项目名称
                       String checkFilterValues,  //需要显示的项目状态
                       String levelFilterValues,  //需要显示的项目级别
                       Integer num,  //用于教秘和副院长查询需要审核的项目数辅助参数值为1
                       Integer mark) {
        log.info("分页查询，参数：{},{},{},{},{},{},{},{},{},{},{}",page,pageSize,roleId,name,jobNumber,startTime,endTime,
                statusId,projectName,mark,checkFilterValues,levelFilterValues);
        PageBean pageBean = teachProjService.page(page,pageSize,roleId,name,jobNumber,startTime,endTime,
                statusId,projectName,mark,checkFilterValues,levelFilterValues,num);
        return Result.success(pageBean);
    }

}
